Browser

open class Browser : ProtocolDomains, Closeable, AutoCloseable

Creates new browser that allows querying remote Chrome instance for debugging sessions

Samples

import pl.wendigo.chrome.Browser
import pl.wendigo.chrome.api.network.EnableRequest
import pl.wendigo.chrome.api.page.NavigateRequest
import pl.wendigo.chrome.sync
fun main() { 
   //sampleStart 
   val browser = Browser
    .builder()
    .withAddress("127.0.0.1:9222")
    .runInDocker(true)
    .multiplexConnections(true)
    .build()

browser.target("about:blank").use { target ->
    sync(target.Page.enable())
    sync(target.DOM.enable())
    sync(target.CSS.enable())
    sync(target.Network.enable(EnableRequest()))

    browser.events().subscribe {
        println("Received browser event $it")
    }

    target.events().subscribe {
        println("Received target event $it")
    }

    sync(
        target.Page.navigate(NavigateRequest(url = "https://github.com/wendigo/chrome-reactive-kotlin")).flatMap { (frameId) ->
            target.Page.frameStoppedLoading().filter { (loadedFrameId) ->
                loadedFrameId == frameId
            }.take(1).singleOrError()
        }
    )

    println("Created target is ${target.targetId()} with session info ${target.session()}")

    browser.targets().forEach {
        println("Target ${it.targetId} has url: ${it.url} and browser context id: ${it.browserContextId}")
    }

    Thread.sleep(100000)
}

browser.close() 
   //sampleEnd
}

Types

BrowserInfo
Link copied to clipboard
data class BrowserInfo(browser: String, protocolVersion: String, userAgent: String, v8Version: String?, webKitVersion: String, webSocketDebuggerUrl: String)
Builder
Link copied to clipboard
class Builder
Builder is responsible for setting options and defaults while creating new instance of Browser.
Companion
Link copied to clipboard
object Companion

Functions

attach
Link copied to clipboard
fun attach(target: TargetInfo): Target
Attaches to existing target creating new session if multiplexed connections is used.
browserInfo
Link copied to clipboard
fun browserInfo(): Browser.BrowserInfo
Returns information on browser.
close
Link copied to clipboard
open override fun close()
Closes session manager and established connection to the debugger.
fun close(target: Target)
Closes target releasing all resources on the browser side and connections.
domains
Link copied to clipboard
fun domains(): List<Domain>
Returns a list of all protocol domain objects.
events
Link copied to clipboard
fun events(): Flowable<Event>
Returns Flowable capturing all events.
protocolVersion
Link copied to clipboard
fun protocolVersion(): String
Returns protocol version.
target
Link copied to clipboard
fun target(url: String = options.blankPage, incognito: Boolean = options.incognito, width: Int = options.viewportWidth, height: Int = options.viewportHeight): Target
Creates new target and opens new debugging session via debugging protocol.
targets
Link copied to clipboard
fun targets(): List<TargetInfo>
Lists all targets that can be attached to.
toString
Link copied to clipboard
open override fun toString(): String

Properties

Accessibility
Link copied to clipboard
val Accessibility: AccessibilityDomain
Lazily returns AccessibilityDomain domain object allowing to invoke methods on Accessibility protocol domain.
Animation
Link copied to clipboard
val Animation: AnimationDomain
Lazily returns AnimationDomain domain object allowing to invoke methods on Animation protocol domain.
ApplicationCache
Link copied to clipboard
val ApplicationCache: ApplicationCacheDomain
Lazily returns ApplicationCacheDomain domain object allowing to invoke methods on ApplicationCache protocol domain.
Audits
Link copied to clipboard
val Audits: AuditsDomain
Audits domain allows investigation of page violations and possible improvements.
BackgroundService
Link copied to clipboard
val BackgroundService: BackgroundServiceDomain
Defines events for background web platform features.
Browser
Link copied to clipboard
val Browser: BrowserDomain
The Browser domain defines methods and events for browser managing.
CacheStorage
Link copied to clipboard
val CacheStorage: CacheStorageDomain
Lazily returns CacheStorageDomain domain object allowing to invoke methods on CacheStorage protocol domain.
Cast
Link copied to clipboard
val Cast: CastDomain
A domain for interacting with Cast, Presentation API, and Remote Playback API functionalities.
Console
Link copied to clipboard
val Console: ConsoleDomain
This domain is deprecated - use Runtime or Log instead.
CSS
Link copied to clipboard
val CSS: CSSDomain
This domain exposes CSS read/write operations.
Database
Link copied to clipboard
val Database: DatabaseDomain
Lazily returns DatabaseDomain domain object allowing to invoke methods on Database protocol domain.
Debugger
Link copied to clipboard
val Debugger: DebuggerDomain
Debugger domain exposes JavaScript debugging capabilities.
DeviceOrientation
Link copied to clipboard
val DeviceOrientation: DeviceOrientationDomain
Lazily returns DeviceOrientationDomain domain object allowing to invoke methods on DeviceOrientation protocol domain.
DOM
Link copied to clipboard
val DOM: DOMDomain
This domain exposes DOM read/write operations.
DOMDebugger
Link copied to clipboard
val DOMDebugger: DOMDebuggerDomain
DOM debugging allows setting breakpoints on particular DOM operations and events.
DOMSnapshot
Link copied to clipboard
val DOMSnapshot: DOMSnapshotDomain
This domain facilitates obtaining document snapshots with DOM, layout, and style information.
DOMStorage
Link copied to clipboard
val DOMStorage: DOMStorageDomain
Query and modify DOM storage.
Emulation
Link copied to clipboard
val Emulation: EmulationDomain
This domain emulates different environments for the page.
Fetch
Link copied to clipboard
val Fetch: FetchDomain
A domain for letting clients substitute browser's network layer with client code.
HeadlessExperimental
Link copied to clipboard
val HeadlessExperimental: HeadlessExperimentalDomain
This domain provides experimental commands only supported in headless mode.
HeapProfiler
Link copied to clipboard
val HeapProfiler: HeapProfilerDomain
Lazily returns HeapProfilerDomain domain object allowing to invoke methods on HeapProfiler protocol domain.
IndexedDB
Link copied to clipboard
val IndexedDB: IndexedDBDomain
Lazily returns IndexedDBDomain domain object allowing to invoke methods on IndexedDB protocol domain.
Input
Link copied to clipboard
val Input: InputDomain
Lazily returns InputDomain domain object allowing to invoke methods on Input protocol domain.
Inspector
Link copied to clipboard
val Inspector: InspectorDomain
Lazily returns InspectorDomain domain object allowing to invoke methods on Inspector protocol domain.
IO
Link copied to clipboard
val IO: IODomain
Input/Output operations for streams produced by DevTools.
LayerTree
Link copied to clipboard
val LayerTree: LayerTreeDomain
Lazily returns LayerTreeDomain domain object allowing to invoke methods on LayerTree protocol domain.
Log
Link copied to clipboard
val Log: LogDomain
Provides access to log entries.
Media
Link copied to clipboard
val Media: MediaDomain
This domain allows detailed inspection of media elementsThis API is marked as experimental in protocol definition and can change in the future.
Memory
Link copied to clipboard
val Memory: MemoryDomain
Lazily returns MemoryDomain domain object allowing to invoke methods on Memory protocol domain.
Network
Link copied to clipboard
val Network: NetworkDomain
Network domain allows tracking network activities of the page.
Overlay
Link copied to clipboard
val Overlay: OverlayDomain
This domain provides various functionality related to drawing atop the inspected page.
Page
Link copied to clipboard
val Page: PageDomain
Actions and events related to the inspected page belong to the page domain.
Performance
Link copied to clipboard
val Performance: PerformanceDomain
Lazily returns PerformanceDomain domain object allowing to invoke methods on Performance protocol domain.
PerformanceTimeline
Link copied to clipboard
val PerformanceTimeline: PerformanceTimelineDomain
Reporting of performance timeline events, as specified in https://w3c.github.io/performance-timeline/#dom-performanceobserver.
Profiler
Link copied to clipboard
val Profiler: ProfilerDomain
Lazily returns ProfilerDomain domain object allowing to invoke methods on Profiler protocol domain.
Runtime
Link copied to clipboard
val Runtime: RuntimeDomain
Runtime domain exposes JavaScript runtime by means of remote evaluation and mirror objects.
Schema
Link copied to clipboard
val Schema: SchemaDomain
This domain is deprecated.
Security
Link copied to clipboard
val Security: SecurityDomain
Security
ServiceWorker
Link copied to clipboard
val ServiceWorker: ServiceWorkerDomain
Lazily returns ServiceWorkerDomain domain object allowing to invoke methods on ServiceWorker protocol domain.
Storage
Link copied to clipboard
val Storage: StorageDomain
Lazily returns StorageDomain domain object allowing to invoke methods on Storage protocol domain.
SystemInfo
Link copied to clipboard
val SystemInfo: SystemInfoDomain
The SystemInfo domain defines methods and events for querying low-level system information.
Target
Link copied to clipboard
val Target: TargetDomain
Supports additional targets discovery and allows to attach to them.
Tethering
Link copied to clipboard
val Tethering: TetheringDomain
The Tethering domain defines methods and events for browser port binding.
Tracing
Link copied to clipboard
val Tracing: TracingDomain
Lazily returns TracingDomain domain object allowing to invoke methods on Tracing protocol domain.
WebAudio
Link copied to clipboard
val WebAudio: WebAudioDomain
This domain allows inspection of Web Audio API.
WebAuthn
Link copied to clipboard
val WebAuthn: WebAuthnDomain
This domain allows configuring virtual authenticators to test the WebAuthn API.

Sources

jvm source
Link copied to clipboard